﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;


namespace LuceneMike
{
    public partial class Form1 : Form
    {

        private string searchFolder = "C:\\IndexDokumente\\";
        private LuceneManager luceneManager;

        public Form1()
        {
            InitializeComponent();
            luceneManager = new LuceneManager(this);
            searchFolder = folderBrowserDialog1.SelectedPath;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }
        

        private void button1_Click(object sender, EventArgs e)
        {
            Debug.WriteLine("Click "+searchFolder.Length);
            if (searchFolder.Length > 0)
            {
                luceneManager.loadDocuments(searchFolder);
            }
            button3.Visible = true;
            label2.Visible = true;
            richTextBox1.Visible = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string folderPath = "";
//            FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                folderPath = folderBrowserDialog1.SelectedPath;
                searchFolder = folderPath;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string query = richTextBox1.Text;
            if (query.Length > 0)
            {
                luceneManager.search(query);
            }
        }

        private void folderBrowserDialog1_HelpRequest(object sender, EventArgs e)
        {

        }

        public void updateOutput(string text)
        {
            richTextBox2.Text = text;
            richTextBox2.Visible = true;
        }
        
    }
}
